from django.conf import settings
from pyplog.config.models import Configuration

class EmptyConfig:
	site = None
	
	author = None
	description = None
	title = None
	title_sub = None
	keywords = None
	
	blog_posts_per_page = 5
	feed_items = 5
	gallery_featured_photos = 7
	google_analytics_id = None
	
class LazyConfig:
	def __getattr__(self, attr):
		if not self.__dict__.has_key("_data"):
			try:
				self.__dict__["_data"] = Configuration.objects.get(site__id = settings.SITE_ID)
			except Configuration.DoesNotExist:
				return getattr(EmptyConfig, attr)
		return getattr(self._data, attr)
		
config = LazyConfig()
